"use strict";
cc._RF.push(module, '4fe24HVridO1JAPBIezAseX', 'IOSSDk');
// scripts/IOSSDk.js

"use strict";

var t = require;
var e = module;
var o = exports;

var _n9,
    i = void 0 && (void 0).__extends || (_n9 = function n(t, e) {
  return (_n9 = Object.setPrototypeOf || {
    __proto__: []
  } instanceof Array && function (t, e) {
    t.__proto__ = e;
  } || function (t, e) {
    for (var o in e) {
      Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
    }
  })(t, e);
}, function (t, e) {
  function o() {
    this.constructor = t;
  }

  _n9(t, e), t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o());
});

Object.defineProperty(o, "__esModule", {
  value: !0
});

var s = t("BaseSdk"),
    r = t("SDK"),
    c = t("PlatfromEnum"),
    a = t("Common"),
    u = function (t) {
  function e() {
    var e = null !== t && t.apply(this, arguments) || this;
    return e._isRecorder = !1, e._recorderShareFunc = null, e._videoOptions = null, e._loginOptions = null, e._recorderTimer = null, e._recorderTimerEnable = !1, e;
  }

  return i(e, t), e.prototype.init = function () {
    var t = this;
    this._recorderTimer = setInterval(function () {
      t._recorderTimerEnable && t.getIsScreenRecordVideo() && t._recorderShareFunc && t._recorderShareFunc();
    });
  }, e.prototype.isOpenShare = function () {
    return this.getIsScreenRecordVideo();
  }, e.prototype.login = function (t) {
    if (this._loginOptions = t, 1 == t.type) this.loginWithDouyin();else if (2 == t.type) {
      var e = this.getAnonymousCode(),
          o = {
        platform: c["default"].IOS,
        openId: e,
        nickName: t.nickName
      };
      this.doLogin(a["default"].simpleLoginUrl, o);
    } else 3 == t.type && this.loginWithApple();
  }, e.prototype.doLogin = function (t, e) {
    var o = this;
    this.sendHttpRequest(t, e, function (t) {
      if (console.log("请求成功", t), t.ok) if (0 == t.error) {
        var e = t.data;
        0 == e.user.status ? (console.log("登录完成，准备回调"), o._loginOptions.success(e)) : (console.log("用户状态异常"), o._loginOptions.fail("你因违规操作,帐号已被系统冻结"));
      } else o._loginOptions.fail(t.error);
    }, function (t) {
      console.log("request调用失败", t), o._loginOptions.fail("网络繁忙,请稍后再试");
    });
  }, e.prototype.getAnonymousCode = function () {
    return jsb.reflection.callStaticMethod("FCTool", "getAnonymousCode");
  }, e.prototype.loginWithDouyin = function () {
    jsb.reflection.callStaticMethod("FCTool", "loginWithDouyin");
  }, e.prototype.loginWithApple = function () {
    jsb.reflection.callStaticMethod("FCTool", "loginWithApple");
  }, e.prototype.dyTokenSuccess = function (t, e) {
    var o = {
      platform: c["default"].IOS,
      openId: e,
      code: t
    };
    this.doLogin(a["default"].dyLoginUrl, o);
  }, e.prototype.appleLoginSuccess = function (t, e) {
    var o = {
      platform: c["default"].IOS,
      openId: t,
      nickName: e
    };
    this.doLogin(a["default"].simpleLoginUrl, o);
  }, e.prototype.loginError = function () {
    this._loginOptions.fail("登录失败");
  }, e.prototype.hasAppleLogin = function () {
    return jsb.reflection.callStaticMethod("FCTool", "hasAppleLogin");
  }, e.prototype.createMoreGamesButton = function () {}, e.prototype.setClipboardData = function (t) {
    console.log("调用剪切板", t.data), jsb.reflection.callStaticMethod("FCTool", "copy:", t.data);
  }, e.prototype.getOpenDataContext = function () {
    return null;
  }, e.prototype.postMessage = function (t) {
    console.log("推送开放数据", t);
  }, e.prototype.startRecorder = function () {
    this._isRecorder = !0;
  }, e.prototype.stopRecorder = function () {
    this._isRecorder = !1;
  }, e.prototype.getIsScreenRecordVideo = function () {
    return jsb.reflection.callStaticMethod("FCTool", "getIsScreenRecordVideo");
  }, e.prototype.getRecorderState = function () {
    return this._isRecorder;
  }, e.prototype.shareRecorder = function (t) {
    var e = this;
    this._recorderTimerEnable = !1, this.getIsScreenRecordVideo() ? (this._shareOptions = t, jsb.reflection.callStaticMethod("FCTool", "shareRecord:miniPragramInfo:", "", "")) : this.stopRecorder(function () {
      e.shareRecorder(t);
    });
  }, e.prototype.shareRecorderSuccess = function () {
    this._shareOptions && this._shareOptions.success && this._shareOptions.success();
  }, e.prototype.shareRecorderFail = function () {
    this._shareOptions && this._shareOptions.fail && this._shareOptions.fail({
      errMsg: "player cancel"
    });
  }, e.prototype.showRewardVideo = function (t) {
    this.getVideoState() && (this._videoOptions = t, jsb.reflection.callStaticMethod("FCTool", "playVideo"));
  }, e.prototype.onVideoSuccess = function () {
    var t = this;
    setTimeout(function () {
      t._videoOptions.success && t._videoOptions.success();
    }, 500);
  }, e.prototype.onVideoFail = function () {
    this._videoOptions.fail && this._videoOptions.fail();
  }, e.prototype.getVideoState = function () {
    return jsb.reflection.callStaticMethod("FCTool", "getVideoStatus");
  }, e.prototype.playScreen = function (t) {
    void 0 === t && (t = 1), jsb.reflection.callStaticMethod("FCTool", "playScreen");
  }, e.prototype.sendEvent = function (t) {
    t && t.key && (t.value || (t.value = {}), console.log("上报事件:", t.key), jsb.reflection.callStaticMethod("FCTool", "beginEventWith:values:", t.key, JSON.stringify(t.value)));
  }, e.prototype.getLanguage = function () {
    return jsb.reflection.callStaticMethod("FCTool", "getLanguage");
  }, e.prototype.vibrateShort = function () {
    this.shock(1);
  }, e.prototype.vibrateLong = function () {
    this.shock(2);
  }, e.prototype.shock = function (t) {
    try {
      jsb.reflection.callStaticMethod("FCTool", "shock:", t);
    } catch (e) {
      console.log("调用手机震动报错:" + e.message);
    }
  }, e.prototype.setLocalStorage = function (t, e) {
    cc.sys.localStorage.setItem(r["default"].gameName + t, e);
  }, e.prototype.getLocalStorage = function (t) {
    return cc.sys.localStorage.getItem(r["default"].gameName + t);
  }, e;
}(s["default"]);

o["default"] = u;

cc._RF.pop();